import { observable, action } from 'mobx';
import BaseListStore from '../BaseListStore';
import * as Apis from '../../apis/ReportApi';
import { Button } from 'antd';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;

class ReportStore extends BaseListStore {
    @observable customDialogTile = getLabel(343, '定制');
    @observable customDialogShow = false;
    @observable chanceDialogTile = getLabel(2227, '销售机会');
    @observable chanceDialogShow = false;
    @observable chanceDialogParams = {};

    @action
    showCustomDialog=(bool = false) => {
      this.customDialogShow = bool;
    }

    @action
    showChanceDialog=(bool = false, obj = {}) => {
      this.chanceDialogShow = bool;
      this.chanceDialogParams = obj;
    }

    getTableData(requestParams, callBackFn) {
      const type = this.routerParams.type;
      Apis.getChanceReport(type, requestParams).then((data) => {
        callBackFn(data);
      });
    }

    excelExport(excelExportCallBack) {
      const type = this.routerParams.type;
      const requestParams = {};
      Apis.getChanceReportExcel(type, requestParams).then((data) => {
        excelExportCallBack(data);
      });
    }

    getTopButtonsCustom() {
      const type = this.routerParams.type;
      const arr = [];
      if (type == 'reportTimeSection') {
        arr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@p6eiih@cutom`} type="primary" onClick={() => { this.showCustomDialog(true); }}>{getLabel(343, '定制')}</Button>);
      }
      return arr;
    }
}
export default ReportStore;
